﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>排线页面</title>
    <meta charset="utf-8" />
    <base target="_self" />
    <meta name="viewport" content="width=device-width">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <script type="text/javascript" src="../../Plat/Flow/lib/jquery-ui-1.8.4.custom/js/jquery-1.4.2.min.js"></script>
    <script type="text/javascript">
        var taskid;
        var WaitDeliveryTime;
        $(document).ready(function () {
            //debugger
            var winHeight = $(window.parent.window).height();
            winHeight = winHeight - 50;
            var iframeMap = $("#CPIFrameMap");
            iframeMap.css("height", winHeight + 'px');
            var taskstr = getQueryString("id");
            if (taskstr != undefined && taskstr != null && taskstr != 0 && taskstr != 1) {
                var strsplit = taskstr.split(",");
                taskid = strsplit[0];
                WaitDeliveryTime = strsplit[1];
                if (strsplit[1] == 0) {
                    $("#btnSetUpBus").hide();
                    $("#btnEditTask").hide()
                }
                $("#IFrameMap").attr("src", "BusinessLineMap?taskid=" + taskid);
            } else {
                $("#btnSetUpBus").hide();
                $("#btnEditTask").hide();
            }

           
            
        });
        var CreateTask = function () {
            var url = "/Plat/Grid/GridView?GridCode=Grid201809211343510060";
            url = top.FormatUrlForOpenNewModel(url, "top", "");
            var winHeigth = $(window.parent.window).height();
            var winWidth = $(window.parent.window).width();
            DelCookie("taskid");
            top.OpenNewModel(url, "配送任务", winWidth, winHeigth);

        };
        var SetUpBus = function () {            
            // var taskid = getQueryString("id");
            // var url = "/Plat/Grid/GridView?GridCode=Grid201809211659440061&taskid=" + taskid;
            var strsplit = taskid.split("_");
            var id = strsplit[0];
            var url = "/Plat/Grid/GridView?GridCode=Grid201810161356250001&taskid=" + id;
            url = top.FormatUrlForOpenNewModel(url, "top", "");
            var OpenWinWidth = 1000;
            var OpenWinHeight = 700;
            top.OpenNewModel(url, "设置配送车辆", OpenWinWidth, OpenWinHeight);

        };
        var EditTask = function () {
            //debugger
            // var taskid = getQueryString('id');
            var strsplit = taskid.split("_");
            var id = strsplit[0];
            var url = "/Plat/Grid/GridView?GridCode=Grid201809271733260069&taskid=" + id + "&WaitDeliveryTime=" + WaitDeliveryTime;
            url = top.FormatUrlForOpenNewModel(url, "top", "");
            var winHeigth = $(window.parent.window).height();
            var winWidth = $(window.parent.window).width();
            top.OpenNewModel(url, "编辑任务", winWidth, winHeigth);

        };
        //获取url中的参数
        var getQueryString = function (name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); // 匹配目标参数
            var result = window.location.search.substr(1).match(reg);  // 对querystring匹配目标参数
            if (result != null) {
                return decodeURIComponent(result[2]);
            } else {
                return null;
            }
        }

        function DelCookie(name) {
            var exp = new Date();
            exp.setTime(exp.getTime() - 1);
            var cval = GetCookie(name);
            top.document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
        }
        function GetCooki(offset) {
            var endstr = top.document.cookie.indexOf(";", offset);
            if (endstr == -1)
                endstr = top.document.cookie.length;
            return decodeURIComponent(top.document.cookie.substring(offset, endstr));
        }
        function GetCookie(name) {
            var arg = name + "=";
            var alen = arg.length;
            var clen = top.document.cookie.length;
            var i = 0;
            while (i < clen) {
                var j = i + alen;
                if (top.document.cookie.substring(i, j) == arg)
                    return GetCooki(j);
                i = top.document.cookie.indexOf(" ", i) + 1;
                if (i == 0) break;
            }
            return null;
        }
    </script>



</head>
<body>
    <div id="CPIFrameContainer">
        <div id="CPIFrameButton">
            <input type="button" value="设置配送车辆" id="btnSetUpBus" onclick="SetUpBus()" />
            <input type="button" value="编辑任务" id="btnEditTask" onclick="EditTask()"/>
            <input type="button" value="创建配送任务" id="btnCreateTask"  onclick="CreateTask()"/>
        </div>
        <div id="CPIFrameMap">
            <iframe id="IFrameMap" src="BusinessLineMap" style="width:100%;height:100%" />
        </div>
    </div>

</body>
</html>
